//
//  CELogListViewController.m
//  C8 Energy
//
//  Created by 颜魏 on 2024/10/1.
//

#import "CELogListViewController.h"

@interface CELogListViewController ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIButton *cleartn;
@property (weak, nonatomic) IBOutlet UITextView *tv;

@end

@implementation CELogListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleLabel.text = NSLocalizedString(@"Log", nil);
    [self.cleartn setTitle:NSLocalizedString(@"Clear", nil) forState:UIControlStateNormal];
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"GET_LOG_DATA" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getData:) name:@"LOG_DATA_SUCCESS" object:nil];
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

#pragma mark - action
- (IBAction)actionBack:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)actionClear:(id)sender {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"LOG_DATA_DELETE" object:nil];
    self.tv.text = @"";
}

- (void)getData:(NSNotification *)notification {
    NSString *str = notification.object ?: @"";
    self.tv.text = str;
}

@end
